type MyLinkedList struct {
    dummyHead *node
    size int
}

type node struct{
    Next *node
    Val int
}

func Constructor() MyLinkedList {
    return MyLinkedList{
        size: 0,
        dummyHead: &node{},
    }
}


func (this *MyLinkedList) Get(index int) int {
    if this.size > index && index >= 0 {
        preNode := this.dummyHead
        for i:=0; i<=index; i++ {
            preNode = preNode.Next
        }
        return preNode.Val
    }
    return -1
}


func (this *MyLinkedList) AddAtHead(val int)  {
    this.AddAtIndex(0, val)
}


func (this *MyLinkedList) AddAtTail(val int)  {
    this.AddAtIndex(this.size, val)
}


func (this *MyLinkedList) AddAtIndex(index int, val int)  {
    if this.size < index {
        return
    }
    newNode := &node{Val: val}
    if index <= 0 {
        index = 0
    }
    preNode := this.dummyHead
    for i:=0; i<index; i++ {
        preNode = preNode.Next
    }
    newNode.Next = preNode.Next
    preNode.Next = newNode
    this.size++
}


func (this *MyLinkedList) DeleteAtIndex(index int)  {
    if index >=0 && index < this.size {
        preNode := this.dummyHead
        for i:=0; i<index; i++ {
            preNode = preNode.Next
        }
        preNode.Next = preNode.Next.Next
        this.size--
    }
}


/**
 * Your MyLinkedList object will be instantiated and called as such:
 * obj := Constructor();
 * param_1 := obj.Get(index);
 * obj.AddAtHead(val);
 * obj.AddAtTail(val);
 * obj.AddAtIndex(index,val);
 * obj.DeleteAtIndex(index);
 */